package com.yb.guigu.pick.activity.interceptor;

import com.yb.guigu.pick.activity.channel.IRedisChannel;
import lombok.extern.slf4j.Slf4j;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;

import java.lang.reflect.Method;

/**
 * Copyright (C), 2022-2023, 姚兵
 * Author: 32210
 * Date: 2023/7/14 16:57
 * FileName: RedisStreamInterceptor
 * Description:
 */


@Slf4j
public abstract class IRedisStreamInterceptor implements MethodInterceptor, BeanNameAware {


    private String beanName;

    @Override
    public Object invoke(MethodInvocation invocation) throws Throwable {
        Object[] arguments = invocation.getArguments();
        Method method = invocation.getMethod();
        Object aThis = invocation.getThis();

        try {

           for (Object argument : arguments) {

               if(argument instanceof IRedisChannel){
                   //设置RedisChannel
               }
           }
           log.info("intercept {}",method);

            Object result = invocation.proceed();

            return result;

       }catch (Exception e){
            log.info("e",e);
            
       }finally {
            
        }
      return   null;
    }

    @Override
    public void setBeanName(@NonNull String name) {
        this.beanName=name;
    }


    public String getBeanName() {
        return beanName;
    }
}
